﻿using Microsoft.Extensions.Configuration;
using NP.BPMReportPlatform.DBHelper;
using NP.BPMReportPlatform.Entities.BPM_Platform;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace NP.BPMReportPlatform.RecurringJobs
{
    public class LogOnlyForStepsClearJob : BpmReportPlatformRecurringJob, ILogOnlyForStepsClearJob
    {
        private readonly SqlSugarClient _dbPlatform;

        public LogOnlyForStepsClearJob(ISqlSugarAppService sqlSugarAppService, IConfiguration configuration)
        {
            _dbPlatform = sqlSugarAppService.GetPlatformInstance();
        }

        public async Task ClearLogOnlyForStepsData()
        {
            var date = DateTime.Today.AddDays(-30);
            await _dbPlatform.Deleteable<LogOnlyForSteps>().Where(x => x.CreateDate < date).ExecuteCommandAsync();
        }
    }
}
